<?php /* Smarty version Smarty-3.1.12, created on 2013-02-27 23:25:45
         compiled from "D:\wamp\www\acps_new\templates\protocol\add.tpl" */ ?>
<?php /*%%SmartyHeaderCode:5254512529338d1ce9-25504300%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '20feed6794a7c3ee9cb27de17097cd73bd630345' => 
    array (
      0 => 'D:\\wamp\\www\\acps_new\\templates\\protocol\\add.tpl',
      1 => 1362007543,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '5254512529338d1ce9-25504300',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.12',
  'unifunc' => 'content_51252933dea172_84204477',
  'variables' => 
  array (
    'data' => 0,
    'counter' => 0,
    'bgClass' => 0,
    'new' => 0,
    'client' => 0,
    'type' => 0,
    'tariff' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_51252933dea172_84204477')) {function content_51252933dea172_84204477($_smarty_tpl) {?><?php if (!is_callable('smarty_modifier_date_format')) include 'D:\\wamp\\www\\acps_new\\libs\\smarty\\libs\\plugins\\modifier.date_format.php';
?><?php echo $_smarty_tpl->getSubTemplate ($_smarty_tpl->tpl_vars['data']->value['pathToError'], $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null, array(), 0);?>

<script type="text/javascript">
    
        
    $(document).ready(function() {
        $("#date").datepicker({ 
            dateFormat: "dd/mm/yy" 
        });
        $(".float").change(function() {
            makeFloat(".float",1);
        });
        $(".double").change(function() {
            makeFloat(".double",2);
        })    
    });    
        
    function showReport(value){
        if (value!=-1){
            
            var data = {
                action : 'show_monthly_report_of_client',
                params: {
                    client: value
                }
            }

            var result = false;

            ajax(data, function (data) {
                if (data.result==0){
                    result = false;
                } else {
                    $("#report").empty();
                    $("#report").append(data.text)
                    result = true;
                }
            });

            return result;
            
        }
    }
        
    function changeTariffs(value){
        if (value!=-1){
            
            var data = {
                action : 'change_tariffs',
                params: {
                    type: value
                }
            }

            var result = false;

            ajax(data, function (data) {
                if (data.result==0){
                    $("#tariff").empty();
                    $("#tariff").append('<option value="-1">Please select</option>');
                    result = false;
                } else {
                    $("#tariff").empty();
                    $("#tariff").append('<option value="-1">Please select</option>');
                    $("#tariff").append(data.options)
                    result = true;
                }
            });

            return result;
            
        }
    }
        
    function fillPrice(value){
        if (value!=-1){
            
            var data = {
                action : 'fill_price',
                params: {
                    tariff: value
                }
            }

            var result = false;

            ajax(data, function (data) {
                if (data.result==0){
                    $("#price").val("0.00");
                    result = false;
                } else {
                    $("#price").val(data.price);
                    makeFloat(".double",2);
                    result = true;
                }
            });

            return result;
            
        }
    }
    
    
</script>
<?php if ($_smarty_tpl->tpl_vars['data']->value['newRecords']){?>
    <h2 class="pageTitle">Records added during this session</h2>
    <table class="list">
        <tr>
            <th>Date</th>
            <th>Client</th>
            <th>Type of record</th>
            <th>Amount</th>
            <th>Tariff</th>
            <th>Unit price</th>
            <th>Description</th>
            <th></th>
            <th></th>
            <th></th>
        </tr>
        <?php $_smarty_tpl->tpl_vars['counter'] = new Smarty_variable(1, null, 0);?>
        <?php  $_smarty_tpl->tpl_vars['new'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['new']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['data']->value['newRecords']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['new']->key => $_smarty_tpl->tpl_vars['new']->value){
$_smarty_tpl->tpl_vars['new']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['new']->key;
?>
            <?php if ($_smarty_tpl->tpl_vars['counter']->value==1){?>
                <?php $_smarty_tpl->tpl_vars['bgClass'] = new Smarty_variable('bgDark', null, 0);?>
            <?php }else{ ?>
                <?php $_smarty_tpl->tpl_vars['bgClass'] = new Smarty_variable('bgLight', null, 0);?>
            <?php }?>
            <tr class="<?php echo $_smarty_tpl->tpl_vars['bgClass']->value;?>
">
                <?php if ($_smarty_tpl->tpl_vars['counter']->value==1){?>
                    <?php $_smarty_tpl->tpl_vars['counter'] = new Smarty_variable(2, null, 0);?>
                <?php }else{ ?>
                    <?php $_smarty_tpl->tpl_vars['counter'] = new Smarty_variable(1, null, 0);?>
                <?php }?>
                <td><?php echo $_smarty_tpl->tpl_vars['new']->value['date_formated'];?>
</td>
                <td><?php echo $_smarty_tpl->tpl_vars['new']->value['client_info']['name'];?>
</td>
                <td><?php echo $_smarty_tpl->tpl_vars['new']->value['type_info']['type_of_record'];?>
</td>
                <td><?php echo $_smarty_tpl->tpl_vars['new']->value['amount'];?>
</td>
                <td>
                    <?php if ($_smarty_tpl->tpl_vars['new']->value['tariff']==-1){?>
                        -
                    <?php }else{ ?>
                        <?php echo $_smarty_tpl->tpl_vars['new']->value['tariff_info']['title'];?>

                    <?php }?>
                </td>
                <td><?php echo $_smarty_tpl->tpl_vars['new']->value['unit_price'];?>
</td>
                <td><?php echo $_smarty_tpl->tpl_vars['new']->value['description'];?>
</td>
                <td><a class="baseLink" href="<?php echo $_smarty_tpl->tpl_vars['data']->value['root'];?>
?input=edit_record&amp;id=<?php echo $_smarty_tpl->tpl_vars['new']->value['recordId'];?>
">Edit</a></td>
                <td><a class="baseLink" href="<?php echo $_smarty_tpl->tpl_vars['data']->value['root'];?>
?input=add_record&amp;copy_id=<?php echo $_smarty_tpl->tpl_vars['new']->value['recordId'];?>
">Copy</a></td>
                <td><a class="baseLink" href="javascript: deleteRecord(<?php echo $_smarty_tpl->tpl_vars['new']->value['recordId'];?>
,'add_record')">Delete</a></td>
            </tr>
        <?php } ?>
    </table>
<?php }?>
<h2 class="pageTitle">Add timesheet-record</h2>
<form class="adding" action="<?php echo $_smarty_tpl->tpl_vars['data']->value['root'];?>
?input=add_record" method="post" onsubmit="return checkAdd_record(
                                                                    $('#date').val(), 
                                                                    $('#client').val(),
                                                                    $('#type').val(),
                                                                    $('#amount').val(),
                                                                    $('#price').val(),
                                                                    $('#description').val()
                                                                                   )">
    <table class="tableForm">
        <tr>
            <td>
                <label for="date">Date <span class="red">*</span> </label>
            </td>
            <td>
                <input name="record[date]" id="date" type="text" value="<?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['date']){?><?php echo $_smarty_tpl->tpl_vars['data']->value['prefill']['date'];?>
<?php }else{ ?><?php echo smarty_modifier_date_format(time(),"%d/%m/%Y");?>
<?php }?>" />
            </td>
            <td id="report" rowspan="7" style="width: 600px; padding-left: 20px">
                <?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['report']){?><?php echo $_smarty_tpl->tpl_vars['data']->value['prefill']['report'];?>
<?php }?>
            </td>    
        </tr>
        <tr>
            <td>
                <label for="client">Client<span class="red">*</span> </label>
            </td>
            <td>
                <select name="record[client]" id="client" size="1" onchange="showReport(this.value)">
                    <option value="-1">Please select</option>
                    <?php  $_smarty_tpl->tpl_vars['client'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['client']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['data']->value['clients']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['client']->key => $_smarty_tpl->tpl_vars['client']->value){
$_smarty_tpl->tpl_vars['client']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['client']->key;
?>
                        <option <?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['client']&&$_smarty_tpl->tpl_vars['data']->value['prefill']['client']==$_smarty_tpl->tpl_vars['client']->value['klient_id']){?>selected="selected"<?php }?> value="<?php echo $_smarty_tpl->tpl_vars['client']->value['klient_id'];?>
"><?php echo $_smarty_tpl->tpl_vars['client']->value['name'];?>
</option>
                    <?php } ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="type">Type of record<span class="red">*</span> </label>
            </td>
            <td>
                <select name="record[type]" id="type" size="1" onchange="changeTariffs(this.value)">
                    <option value="-1">Please select</option>
                    <?php  $_smarty_tpl->tpl_vars['type'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['type']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['data']->value['types']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['type']->key => $_smarty_tpl->tpl_vars['type']->value){
$_smarty_tpl->tpl_vars['type']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['type']->key;
?>
                        <option <?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['type']&&$_smarty_tpl->tpl_vars['data']->value['prefill']['type']==$_smarty_tpl->tpl_vars['type']->value['Id']){?>selected="selected"<?php }elseif($_smarty_tpl->tpl_vars['type']->value['Id']==1){?>selected="selected"<?php }?> value="<?php echo $_smarty_tpl->tpl_vars['type']->value['Id'];?>
"><?php echo $_smarty_tpl->tpl_vars['type']->value['type_of_record'];?>
</option>
                    <?php } ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="amount">Amount <span class="red">*</span> </label>
            </td>
            <td>
                <input name="record[amount]" id="amount" class="float" type="text" value="<?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['amount']){?><?php echo $_smarty_tpl->tpl_vars['data']->value['prefill']['amount'];?>
<?php }?>" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="tariff">Tariff<span class="red"></span> </label>
            </td>
            <td>
                <select name="record[tariff]" id="tariff" size="1" onchange="fillPrice(this.value)">
                    <option value="-1">Please select</option>
                    <?php  $_smarty_tpl->tpl_vars['tariff'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['tariff']->_loop = false;
 $_smarty_tpl->tpl_vars['key'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['data']->value['tariffs']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['tariff']->key => $_smarty_tpl->tpl_vars['tariff']->value){
$_smarty_tpl->tpl_vars['tariff']->_loop = true;
 $_smarty_tpl->tpl_vars['key']->value = $_smarty_tpl->tpl_vars['tariff']->key;
?>
                        <option <?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['tariff']&&$_smarty_tpl->tpl_vars['data']->value['prefill']['tariff']==$_smarty_tpl->tpl_vars['tariff']->value['Id']){?>selected="selected"<?php }?> value="<?php echo $_smarty_tpl->tpl_vars['tariff']->value['Id'];?>
"><?php echo $_smarty_tpl->tpl_vars['tariff']->value['title'];?>
</option>
                    <?php } ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <label for="price">Unit price<span class="red">*</span> </label>
            </td>
            <td>
                <input name="record[price]" id="price" class="double" type="text" value="<?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['unit_price']){?><?php echo $_smarty_tpl->tpl_vars['data']->value['prefill']['unit_price'];?>
<?php }?>" />
            </td>
        </tr>
        <tr>
            <td>
                <label for="description">Description <span class="red">*</span></label>
            </td>
            <td>
                <textarea cols="30" rows="5" name="record[description]" id="description"><?php if ($_smarty_tpl->tpl_vars['data']->value['prefill']['description']){?><?php echo $_smarty_tpl->tpl_vars['data']->value['prefill']['description'];?>
<?php }?></textarea>
            </td>
        </tr>
        <tr class="submitRow">
            <td>
                <input name="action" value="add_record" type="hidden" />
            </td>
            <td>
                <input type="submit" value="Add record" name="add_record" /> &nbsp; 
                <span class="red">* Required</span>
            </td>
            <td></td>
        </tr>
    </table>
</form><?php }} ?>